import bpy

from 全局控制.Node.节点和插座基类 import bl_容器节点

import engine.initLIB.load_dll as engineLib
import ctypes

engineLib.flexCAPI.f_取节点调试数据.restype = ctypes.py_object




g_当前节点 = None
g_当前节点树 = None


class NODE_PT_节点调试面板(bpy.types.Panel):
	bl_space_type = 'NODE_EDITOR'
	bl_region_type = 'UI'
	bl_label = "节点调试面板"

	@classmethod
	def poll(cls, context):
		#print('cls = ', cls)
		global g_当前节点树
		if context.active_node :
			g_当前节点树 = context.active_node.id_data
			return True
		else:
			return False

	def draw(self, context):
		layout = self.layout
		node = context.active_node
		global g_当前节点树

		if g_当前节点树 == None or node == None: return
		
		layout.prop(g_当前节点树, 'm_是否开启节点调试')

		if g_当前节点树.m_是否开启节点调试:
			col = layout.column()
			
			data = engineLib.flexCAPI.f_取节点调试数据(ctypes.c_wchar_p(g_当前节点树.name), ctypes.c_wchar_p(node.name), ctypes.py_object(''))
			if data :
				col.label(text=node.bl_static_type)
				for e in data:
					col.label(text=e)









classes = (
	NODE_PT_节点调试面板,
)

def register():
	bpy.types.NodeTree.m_是否开启节点调试 = bpy.props.BoolProperty(name='节点调试', default=False)

	for c in classes:
		bpy.utils.register_class(c)
		
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)


